package lium.lbs.lbsim.adapter

import android.content.Intent
import android.widget.LinearLayout
import android.widget.TextView
import com.buz.hjcdriver.bean.MessageBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.qmuiteam.qmui.widget.QMUIRadiusImageView
import lium.lbs.lbsim.R
import lium.lbs.lbsim.activity.MainActivity
import lium.lbs.lbsim.jgchat.activity.ChatActivity

class MessageListAdapter : BaseQuickAdapter<MessageBean, BaseViewHolder>(R.layout.item_messgaelist){

    override fun convert(helper: BaseViewHolder?, item: MessageBean?) {

        when(item!!.msg_type){
                //     val MSG_SYSTEM: Int = 0  //系统
            //        val MSG_FRIENDS: Int = 1  //  好友
            //        val MSG_GROUP: Int = 2  // 群组
            MessageBean.MSG_SYSTEM -> {
                (mContext as MainActivity)?.displayImage(item.head,R.drawable.icon_msg_system,helper!!.getView<QMUIRadiusImageView>(R.id.contacts_head))
            }
            MessageBean.MSG_FRIENDS -> {
                (mContext as MainActivity)?.displayImage(item.head,R.drawable.touxiangnan,helper!!.getView<QMUIRadiusImageView>(R.id.contacts_head))
            }
            MessageBean.MSG_GROUP -> {
                (mContext as MainActivity)?.displayImage(item.head,R.drawable.touxianggroup,helper!!.getView<QMUIRadiusImageView>(R.id.contacts_head))
            }
        }
        helper!!.getView<TextView>(R.id.msg_name).text = item.name+""
        helper!!.getView<TextView>(R.id.msg_msg).text = item.msg+""
        helper!!.getView<LinearLayout>(R.id.content).setOnClickListener {
            val intent = Intent(mContext, ChatActivity::class.java)
            mContext.startActivity(intent)
        }


    }


}